public class Solution {
    //仅仅反转字母
    public String reverseOnlyLetters(String s) {
        int left = 0;
        int right = s.length()-1;
        char[] arr = s.toCharArray();
        while(left < right) {
            if(left >= right) {
                break;
            }
            //left走到左边字母位置
            while(left < right &&  !Character.isLetter(arr[left]) ) {
                left++;
            }
            //right走到右边字母位置
            while(left < right &&  !Character.isLetter(arr[right])) {
                right--;
            }
            //交换位置
            char tmp = arr[left];
            arr[left] = arr[right];
            arr[right] = tmp;
            left++;
            right--;
        }
        String s1 = "";
        for(int i = 0; i < arr.length; i++) {
            s1+=arr[i];
        }
        return s1;
    }
}
